﻿@{
    ViewData["Title"] = "Index";
    Layout = "~/Areas/Console/Views/Shared/_Layout.cshtml";
}
@section head{
    <style type="text/css">
        .layui-table-cell {
            height: 52px;
            line-height: 52px;
        }
    </style>
    <script type="text/javascript">
        var table;
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['table', 'form', 'transfer'], function () {
            var $ = layui.$
                , form = layui.form
                , table = layui.table
                , transfer = layui.transfer
            loadcharges()
            loadnature()

            function loadcharges() {
                $.ajax({
                    type: "GET",
                    url: "/Console/Information/GetCharge",
                    async: true,
                    error: function (request) {
                        alert("请求超时");
                    },
                    beforeSend: function (xhr) {
                        layui.layer.load();
                    },
                    success: function (data) {
                        var item = eval(data);
                        if (item.code == 0) {
                            transfer.render({
                                elem: '#charges-transfer'
                                , data: item.data
                                , value: item.value
                                , title: ['可选项', '已选项']
                                , id: 'charges'
                            })
                        } else {
                            layer.msg(item.msg, { icon: 2 });
                        }
                        layer.closeAll('loading');
                    }
                });
            }

            function loadnature() {
                $.ajax({
                    type: "GET",
                    url: "/Console/Information/GetNature",
                    async: true,
                    error: function (request) {
                        alert("C请求超时");
                    },
                    beforeSend: function (xhr) {
                        layui.layer.load();
                    },
                    success: function (data) {
                        var item = eval(data);
                        if (item.code == 0) {
                            transfer.render({
                                elem: '#nature-transfer'
                                , data: item.data
                                , value: item.value
                                , title: ['可选项', '已选项']
                                , id: 'nature'
                            })
                        } else {
                            layer.msg(item.msg, { icon: 2 });
                        }
                        layer.closeAll('loading');
                    }
                });
            }

            /* 监听提交 */
            form.on('submit(submit-form)', function (data) {
                var params = {};
                params["jointime"] = $("#jointime").val();
                params["joinpersonranking"] = $("#joinpersonranking").val();
                params["charges"] = transfer.getData('charges');
                params["nature"] = transfer.getData('nature');
                $.ajax({
                    type: "POST",
                    url: "/Console/Information/SaveSetting",
                    data: params, // 你的formid
                    async: true,
                    error: function (request) {
                        alert("请求超时");
                    },
                    beforeSend: function (xhr) {
                        layui.layer.load();
                    },
                    success: function (data) {
                        var item = eval(data);
                        if (item.code == 0) {
                            layer.msg("设置成功", { icon: 1, time: 1000 });
                        } else if (item.code == 1) {
                            layer.msg(item.data, { icon: 2 });
                        } else {
                            layer.msg("保存失败", { icon: 0 });
                        }
                        layer.closeAll('loading');
                    }
                });
                return false;
            });
        });
    </script>
}
    <div class="layui-fluid">
        <div class="layui-card">
            @*<div class="layui-card-header">编辑模板</div>*@
            <div class="layui-card-body" style="padding: 15px; ">
                <form class="layui-form layui-form-pane" action="" lay-filter="component-form-group">
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width:260px;">涉案次数设置</label>
                        <div class="layui-input-inline">
                            <input type="text" id="jointime" name="jointime" lay-verify="number" autocomplete="off" class="layui-input" value="@ViewBag.jointime">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width:260px;">共同涉案关联频次排序取值范围设置</label>
                        <div class="layui-input-inline">
                            <input type="text" id="joinpersonranking" name="joinpersonranking" lay-verify="number" autocomplete="off" class="layui-input" value="@ViewBag.joinpersonranking">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"  style="width:260px;">罪名算法范围设置</label>
                        <div id="charges-transfer" name="charges-transfer" class="demo-transfer"></div>
                    </div>
                    <div class="layui-form-item" >
                        <label class="layui-form-label" style="width:260px;">共同犯罪性质算法范围设置</label>
                        <div id="nature-transfer" name="nature-transfer" class="demo-transfer"></div>
                    </div>
                    <div class="layui-form-item layui-layout-admin">
                        <div class="layui-input-block">
                            <div class="layui-footer" style="left: 0;">
                                <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="submit-form">立即提交</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>